package com.zc.portal.iface.repository.impl;

import com.zc.portal.domain.pojo.PcmcUser;
import com.zc.portal.iface.repository.PcmcUserRepository;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository(value = "pcmcUserRepository")
public class PcmcUserRepositoryImpl implements PcmcUserRepository {

    @Autowired
    private SqlSessionTemplate sessionTemplate;

    @Override
    public List<PcmcUser> queryAll() {
        return sessionTemplate.selectList(NAME_SPACE + "queryAll");
    }

    @Override
    public PcmcUser queryPcmcUser(PcmcUser user) {

        return sessionTemplate.selectOne(NAME_SPACE + "queryPcmcUser", user);
    }

    @Override
    public PcmcUser queryPcmcUserByCode(String userCode) {
        return sessionTemplate.selectOne(NAME_SPACE + "queryPcmcUserByCode", userCode);
    }

    @Override
    public PcmcUser queryPcmcUserById(Integer userId) {
        return sessionTemplate.selectOne(NAME_SPACE + "queryPcmcUserByCode", userId);
    }

    @Override
    public String queryPassword(String userCode) {
        return sessionTemplate.selectOne(NAME_SPACE + "queryPassword", userCode);
    }

    @Override
    public String queryUserNameByCode(String userCode) {
        return sessionTemplate.selectOne(NAME_SPACE + "queryUserNameByCode", userCode);
    }

    @Override
    public String queryUserNameById(Integer userId) {
        return sessionTemplate.selectOne(NAME_SPACE + "queryUserNameById", userId);
    }

    @Override
    public int deletePcmcUserByCode(String userCode) {
        return sessionTemplate.delete(NAME_SPACE + "deletePcmcUserByCode", userCode);
    }

    @Override
    public int deletePcmcUserById(Integer id) {
        return sessionTemplate.delete(NAME_SPACE + "deletePcmcUserById", id);
    }

    @Override
    public int updatePcmcUser(PcmcUser pcmcUser) {
        return sessionTemplate.update(NAME_SPACE + "updatePcmcUser", pcmcUser);
    }

    @Override
    public int insertPcmcUser(PcmcUser pcmcUser) {
        return sessionTemplate.update(NAME_SPACE + "insertPcmcUser", pcmcUser);
    }
}
